﻿


using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.TextCore.Text;

namespace Gameplay.CharacterFramework
{
    public class PlayerController:CharacterController
    {
        private Vector2 _moveInput;
        private bool _isJumping;
        private bool _isAttacking;
        private bool attacking;
       
        private Player _player;
        private void Awake()
        {
            _player = GetComponent<Player>();
        }
        
        public void GetMoveInput(InputAction.CallbackContext ctx)
        {
            _moveInput = ctx.ReadValue<Vector2>();
        }
        public void GetJumpInput(InputAction.CallbackContext ctx)
        {
            _isJumping = ctx.ReadValueAsButton();
        }
        public void GetAttackInput(InputAction.CallbackContext ctx)
        {
            _isAttacking = ctx.ReadValueAsButton();
            attacking = false;
        }
        private void Update()
        {
            
            if (_isAttacking&&!attacking)
            {
                attacking = true;

                _player.UseSkill(1002);
            }
            if (Input.GetKeyDown(KeyCode.F1))
            {
                _player.WeaponManager.SelectWeapon(10005);
            }
            if (Input.GetKeyDown(KeyCode.F2))
            {
                _player.WeaponManager.SelectWeapon(10006);
            }
            if (Input.GetKeyDown(KeyCode.F3))
            {
                _player.WeaponManager.SelectWeapon(10003);
            }
        }
        private void FixedUpdate()
        {
            Vector3 dir = new Vector3(_moveInput.x, 0, _moveInput.y);
            _player.Move(dir);
        }
    }
}
